<template>
	<view class="wallet-page">
		<u-navbar :autoBack="true" title="我的钱包" :placeholder="true" bgColor="rgba(255,255,255,0)"></u-navbar>
		<view class="content">
			<view class="my-wallet">
				<image src="https://m.lqvvvv.com/assets/static/my/my-wallet.png" mode=""></image>
			</view>
			<view class="wallet-box">
				<view class="wallet-head">
					<view class="name">
						闪闪的向日葵的钱包
					</view>
					<view class="security">
						<image src="https://m.lqvvvv.com/assets/static/my/security.png" mode=""></image>
						<view>
							安全保障中
						</view>
					</view>
				</view>
				<view class="balance">
					<view class="balance-title">
						我的余额（元）
					</view>
					<view class="balance-text">
						{{info.money || 0}}
					</view>
				</view>
				<!-- #ifdef APP || H5 -->
				<view class="ability"  v-if="info.is_adolescent == 0">
					<view class="ability-item" @click="goRecharge">
						<image src="https://m.lqvvvv.com/assets/static/my/recharge.png" mode=""></image>
						<view class="ability-text">
							充值
						</view>
					</view>
					<view class="line"></view>
					<view class="ability-item" @click="goWithdrawal">
						<image src="https://m.lqvvvv.com/assets/static/my/withdrawal.png" mode=""></image>
						<view class="ability-text">
							提现
						</view>
					</view>
				</view>
				<view v-else style="height: 30rpx;"></view>
				<!-- #endif -->
				<!-- #ifdef MP-WEIXIN -->
				<view class="ability"  v-if="info.is_adolescent == 0 && isshow == 0">
					<view class="ability-item" @click="goRecharge">
						<image src="https://m.lqvvvv.com/assets/static/my/recharge.png" mode=""></image>
						<view class="ability-text">
							充值
						</view>
					</view>
					<view class="line"></view>
					<view class="ability-item" @click="goWithdrawal">
						<image src="https://m.lqvvvv.com/assets/static/my/withdrawal.png" mode=""></image>
						<view class="ability-text">
							提现
						</view>
					</view>
				</view>
				<!-- #endif -->
			</view>
			<view class="bill-title">
				<image src="https://m.lqvvvv.com/assets/static/my/bill.png" mode=""></image>
			</view>
			<view class="recharge-item" v-for="(item,index) in list" :key="index">
				<view class="recharge-left">
					<view class="">
						<image src="https://m.lqvvvv.com/assets/static/my/recharge.png" mode=""></image>
					</view>
					<view class="recharge-info">
						<view class="info-text">
							{{item.memo}}
						</view>
						<view class="info-time">
							{{$u.timeFormat(item.createtime, 'yyyy年mm月dd日 hh:MM:ss')}}
						</view>
					</view>
				</view>
				<view class="price">
					{{item.money}}
				</view>
			</view>
			<u-loadmore :status="status" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {},
				list: [],
				page: 1,
				isshow:0,
				status: 'loadmore',
			}
		},
		onLoad() {
			this.getuserinfo()
			this.postlist()
		},
		onShow() {
			// #ifdef MP-WEIXIN
			this.showinfo()
			// #endif
		},
		onReachBottom() {
			this.page = this.page + 1
			this.status = 'loading';
			this.postlist()
		},
		methods: {
			showinfo() {
				let params = {
					// #ifdef APP
					name: 'hide_status',
					// #endif
					// #ifdef MP-WEIXIN
					name: 'miniapp_hide_status'
					// #endif
				}
				this.$Request({
					method: 'POST',
					url: '/api/index/getConfig',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						console.log(res)
						this.isshow = res.data
					}
				})
			},
			postlist() {
				let params = {
					page: this.page,
					limit:10
				}
				this.$Request({
					method: 'POST',
					url: '/api/user/moneyLog',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						if (res.data.data.length < 10) {
							this.status = 'nomore';
						}
						if (this.page == 1) {
							this.list = res.data.data
						} else {
							this.list = [...this.list, ...res.data.data]
						}

					}
				})
			},
			getuserinfo() {
				this.$Request({
					method: 'POST',
					url: '/api/user/getMyInfo',
					data: {},
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						this.info = res.data
					} else {
						this.info = {}
					}
				})
			},
			goRecharge() {
				uni.navigateTo({
					url: '/pages/my/wallet/recharge'
				})
			},
			goWithdrawal() {
				uni.navigateTo({
					url: '/pages/my/wallet/withdrawal'
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.wallet-page {
		min-height: 100vh;
		background-image: url('https://m.lqvvvv.com/assets/static/index/nav-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 800rpx;
		

		.content {
			padding: 30rpx;

			.my-wallet {
				image {
					width: 154rpx;
					height: 48rpx;
				}
			}

			.wallet-box {
				background-image: url('https://m.lqvvvv.com/assets/static/my/wallet-bg.png');
				background-repeat: no-repeat;
				background-size: 100% 100%;
				margin-top: 30rpx;
				padding-bottom: 10rpx;

				.wallet-head {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 20rpx 40rpx;
					border-bottom: 1rpx solid #ffffff;

					.name {
						font-size: 28rpx;
						color: #2E314A;
						font-weight: bold;
					}

					.security {
						display: flex;
						align-items: center;
						font-size: 24rpx;
						color: #8B8DA0;

						image {
							width: 26rpx;
							height: 26rpx;
							margin-right: 5rpx;
						}
					}
				}

				.balance {
					padding: 30rpx 30rpx 0;

					.balance-title {
						color: #2E314A;
						font-size: 24rpx;
						margin-top: 10rpx;
					}

					.balance-text {
						font-size: 64rpx;
						color: #5755F2;
						font-weight: bold;
						margin-top: 30rpx;
					}
				}

				.ability {
					background-color: #F6F8FA;
					padding: 40rpx;
					border-radius: 30rpx;
					margin: 20rpx;
					display: flex;
					justify-content: space-around;
					align-items: center;
					font-size: 28rpx;

					.ability-item {
						display: flex;
						justify-content: space-around;
						align-items: center;

						image {
							width: 48rpx;
							height: 48rpx;
							margin-right: 30rpx;
						}
					}

					.line {
						background-color: #D9D9D9;
						width: 2rpx;
						height: 36rpx;
					}
				}
			}

			.bill-title {
				margin-top: 40rpx;

				image {
					width: 181rpx;
					height: 46rpx;
				}
			}

			.recharge-item {
				padding: 20rpx 30rpx;
				background-color: #ffffff;
				border-radius: 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 30rpx;

				.recharge-left {
					width: 70%;
					display: flex;
					align-items: center;

					image {
						width: 50rpx;
						height: 50rpx;
					}

					.recharge-info {
						margin-left: 30rpx;

						.info-text {
							color: #000000;
							font-size: 28rpx;
							font-weight: 600;
						}

						.info-time {
							color: #9799AC;
							font-size: 24rpx;
							margin-top: 10rpx;
						}
					}
				}

				.price {
					color: #5755F2;
					font-size: 36rpx;
					font-weight: bold;
				}

				.withdrawal {
					color: #FF4C4F;
				}
			}

		}
	}
</style>